<!DOCTYPE html>
<html>
<head>
    <title>登录</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
    <div class="logo"><img src="img/logo.png"></div>
    <div class="planet"><img src="img/Planet.png"></div>
    <div class="wrapper">
        <p>智慧气象 吴江地区气象科普馆</p>
        <div class="input-wrapper">
            <img class="user" src="img/user.png">
            <input id="unameTxt" class="input-edit" type="text" placeholder="用户名" name="">
        </div>
        <div class="input-wrapper">
            <img class="lock" src="img/lock.png">
            <input id="pwdTxt" class="input-edit pass" type="password" placeholder="密码" name="">
        </div>
        <button class="btn">Let's Go</button>
        <div class="text-wrapper">
            <!-- <span class="text-left">Forgot password?</span>
            <span class="text-right">New here? Sign Up!</span> -->
        </div>
    </div>
    <div class="clouds"><img src="img/clouds.png"></div>
</body>
</html>
<script src="../js/jquery-3.4.1.min.js"></script>
<script src="../js/sweetalert.min.js"></script>
<script type="text/javascript">
    document.body.addEventListener('focusout', () => {
        if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
            // 软键盘收起的事件处理
            setTimeout(() => {
                document.documentElement.scrollTop--
                document.body.scrollTop--
            }, 100)
        }
    });

    $(document).ready(function(){
        $(".btn").click(function(){
            var _un = $("#unameTxt").val();
            var _pwd = $("#pwdTxt").val();

            if (_un !== null && _un !== ''  && _pwd !== null && _pwd !== '') {
                $.post("/api/login_m",
                {
                    uname:$("#unameTxt").val(),
                    pwd:$("#pwdTxt").val()
                },
                function(data,status) {
                    if(status == 'success' && data == '1') {
                        console.log("登录 成功");
                        window.location.href='index.html';
                    } else swal("用户名密码不正确！");
                });
            } else {
                swal("用户名密码不能为空！");
                return;
            }
        });

    });
</script>